﻿using System;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Fawcett.Plugins;
using System.Configuration;
using System.Diagnostics;
using System.Windows.Forms;


namespace Fawcett.Plugins.Panels
{
    public class PFDTestFacility : CPlugin
    {
        public PFDTestFacility()
        {
            Console.WriteLine("Hunting down PFD Test Panel");
        }

        private RibbonButton btnDisplay = new System.Windows.Forms.RibbonButton();
        private MainForm mainForm = new Fawcett.Plugins.Panels.MainForm();
        public override TabLocation Location { get { return TabLocation.SYSTEM; } }
        public override RibbonTab SetupMenu( RibbonTab HomeTab )
        {
            RibbonTab NewTab = HomeTab ;
            RibbonPanel AddonPanel = new RibbonPanel("Pilots Display");

            btnDisplay.Image = Resources.Desktop.ToBitmap();
            btnDisplay.Text = "Show";
            btnDisplay.Click += new EventHandler(this.Show);


            AddonPanel.Items.Add(btnDisplay);

            AddonPanel.ButtonMoreEnabled = false;
            AddonPanel.ButtonMoreVisible = false;

            NewTab.Panels.Add(AddonPanel);


            return null;
        }


        private void List(object sender, EventArgs e)
        {
    //        MappingCollection bar = (MappingCollection)ConfigurationManager.GetSection("WarningPanel");

    //        ListForm<MappingCollection> nf = new ListForm<MappingCollection>("List of Mappings", bar);

 //
      //      if (nf.MdiParent == null) nf.MdiParent = this.parent;

       //     nf.Show();
        }

        private void Show(object sender, EventArgs e)
        {

            if (mainForm.MdiParent == null) mainForm.MdiParent = this.parent;

            if (mainForm.Visible == true)
            {
               mainForm.Hide();
            }
            else
            {
               mainForm.Show();
            }       
        
        }
    }
}
